package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author: lzj
 * @date: 2025/10/11 10:04
 * @description: 优惠卷活动 相关接口
 */
@Api(tags = {": 优惠卷活动 相关接口"})
@RestController
@RequestMapping("operation/activity")
@RequiredArgsConstructor
public class MarketActivityController {

    private final IActivityService activityService;


    @PostMapping("/save")
    public void save(@RequestBody ActivitySaveReqDTO reqDTO) {
        activityService.saveActivity(reqDTO);
    }

    /**
     * 获取优惠券活动列表
     *
     * @param reqDTO 请求参数
     * @return 优惠券活动列表
     */
    @GetMapping("/page")
    public PageResult<ActivityInfoResDTO> page(ActivityQueryForPageReqDTO reqDTO) {
        return activityService.pageActivityPage(reqDTO);
    }

    /**
     * 查询活动详情
     *
     * @param id 活动id
     */
    @GetMapping("/{id}")
    public ActivityInfoResDTO getByActivityId(@PathVariable Long id) {
        return activityService.getByActivityId(id);
    }
    /**
     * 撤销活动
     * @param id 活动id
     */
    @PostMapping("/revoke/{id}")
    public void revokeActivity(@PathVariable Long id) {
        activityService.revokeActivity(id);
    }
}
